using SharpGraphT.Sharp.System.Collections.Generic;

namespace SharpGraphT.Util;

[Serializable]
public class ArrayUnenforcedSet<TE> : List<TE>, IReadOnlyableSet<TE> {
    private static readonly long SerialVersionUid = 5936902837403445985L;

    public ArrayUnenforcedSet() { }

    public ArrayUnenforcedSet(ICollection<TE> c) : base(c) { }

    public static ArrayUnenforcedSet<TE> CreateInstance<TEe>(ICollection<TEe> c)
        where TEe : TE =>
        new(c.Select(p => (TE) p).ToList());

    public ArrayUnenforcedSet(int n) : base(n) { }

    // 这里没有按照JGraphT的equals实现Equals。
    // 参考SetEquals。
    public override bool Equals(object obj) => base.Equals(obj);

    bool ISet<TE>.SetEquals(IEnumerable<TE> other) =>
        new HashSet<TE>(this).SetEquals(other);

    bool IReadOnlySet<TE>.SetEquals(IEnumerable<TE> other) =>
        new HashSet<TE>(this).SetEquals(other);

    // 这里没有按照JGraphT的hashCode实现GetHashCode。
    // 等未来单元测试遇到问题时再考虑解决方案。
    public override int GetHashCode() => base.GetHashCode();

    bool ISet<TE>.Add(TE item) {
        Add(item);
        return true;
    }

    public void ExceptWith(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public void IntersectWith(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public bool IsProperSubsetOf(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public bool IsProperSupersetOf(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public bool IsSubsetOf(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public bool IsSupersetOf(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public bool Overlaps(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public void SymmetricExceptWith(IEnumerable<TE> other) =>
        throw new InvalidOperationException();

    public void UnionWith(IEnumerable<TE> other) =>
        throw new InvalidOperationException();
}